package com.lwd1513.designPattern.factory.responsibilitychain;

/**
 * @Author: 刘东（挂兰）
 * @Date: 2023/11/17 23:58:13
 * @Description:
 */
public class Start {
    public static void main(String[] args) {
        // 组转责任链
        // Spirng 中可以通过注入组转
        RobotHandler startHandler = buildResponsibilitychain();
        // 请求的参数
        RobotRequest robotRequest = new RobotRequest();
        Robot robot = new Robot();
        Object handle = startHandler.handle(robotRequest, robot);
        KnClientResponse knClientResponse = (KnClientResponse) handle;
        System.out.println("result:" + knClientResponse.getResult());

    }

    private  static RobotHandler buildResponsibilitychain() {
        RobotHandlerOne robotHandlerOne = new RobotHandlerOne();
        RobotHandlerTwo robotHandlerTwo = new RobotHandlerTwo();
        RobotHandlerThree robotHandlerThree = new RobotHandlerThree();
        robotHandlerOne.setNextRobotHandler(robotHandlerTwo);
        robotHandlerTwo.setNextRobotHandler(robotHandlerThree);
        return robotHandlerOne;
    }
}
